<?php

namespace app\adminmall\controller;
use app\adminmall\model\BargrecordModel;
use app\common\controller\AdminBaseController;
use think\Db;
/**
 *保证金
 */
class BargrecordController extends AdminBaseController
{
 	 protected $model;
	
    protected function _initialize() {
        parent::_initialize();
        $this->model = new BargrecordModel();
    }
    /**
     * 保证金列表
     * @author [longx] 
     */
    public function index( $page = 1){
        $list = $this->model->paginate(10);
            $dd=$this->model
                     ->table('long_mall_paylog a,long_mall_agent b')                    
                     ->where('a.id=b.id')
                     ->select();                
            return $this->fetch('index', ['list1' => $list, 'list1' => $dd]);
    }
    
    /**
     * 搜索查询
     * @author [longx] 
     */
    public function search(){
    	$map = [];
		$field = 'm.*,g.id,g.store_name';		    	
    	if(request()->isPost()){
		 	$param = input('post.');		
			//用户名称
			if($param['storename']){
				$map['g.store_name'] = ['like', '%'.$param['storename'].'%'];
			}
			//创建时间
			if($param['add_time']&&$param['end_time']){
				$map['m.add_time'] = ['between time', [$param['add_time'],$param['end_time']]];
			}
		}
		$dd=Db::name("mall_paylog")->alias('m')->join('__MALL_AGENT__ g','g.id=m.id')->field($field)->where($map)->paginate(10);
        return $this->fetch('index', ['list1' => $dd]);
	 	}
   
    /**
     * [del删除]
     * @author [longx] 
     */
    public function delete()
    {
        $id = input('param.id');
        if ($this->model->destroy($id)) {
            $this->success('删除成功');
        } else {
            $this->error('删除失败');
        }
    }
}